package com.smart.seckilldemo.controller;



import com.smart.seckilldemo.commons.result.ResponseResult;
import com.smart.seckilldemo.pojo.User;
import com.smart.seckilldemo.service.GoodsService;
import com.smart.seckilldemo.service.OrderService;
import com.smart.seckilldemo.service.SeckillOrderService;
import com.smart.seckilldemo.service.SeckillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 秒杀
 */
@Slf4j
@Controller
@RequestMapping("/seckill")
public class SeckillController {

    @Resource
    SeckillService service;


    /**
     * 一个用户 仅限一件商品  秒杀
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/doSeckill",method = RequestMethod.POST)
    public ResponseResult doSeckill(Long userId, Long goodsId,Integer number){
        return service.Seckill(userId,goodsId,number);
    }

    /**
     * 预热数据
     */
    @GetMapping("/load")
    public void DataLoaderSeckill(){
        service.DataLoaderSeckill();
    }


}
